import grace from "../../utils/grace.js"
grace.page({
      data: {
            list: [],
            param: {
                  pageCurrent: 1,
                  pageSize: 20
            },
            hasMore: true
      },
      onLoad: function (options) {
            this.loadData();
      },
      loadData: function () {
            let param = this.$data.param;
            this.$http.get('api/user/integral_log_list', param)
                  .then((res) => {
                        let hasMore = res.list.length >= this.$data.param.pageSize;
                        const data = this.$data.param.pageCurrent == 1 ? res.list : this.$data.list.concat(res.list);
                        this.$data = {
                              list: data,
                              hasMore: hasMore
                        };
                  })
      },
      onPullDownRefresh: function () {
            this.$data.param.pageCurrent = 1;
            this.loadData();
      },
      onReachBottom: function () {
            if (this.$data.hasMore) {
                  ++this.$data.param.pageCurrent;
                  this.$data.hasMore = false;
                  this.loadData();
            }
      },
})